#include "DragDrop.h"

void DropSystem::init(WindowFramework* a_prop)
{
	m_prop = a_prop;
	ZeroMemory(&msg, sizeof(MSG));
	DragAcceptFiles(m_prop->m_hWnd,true);
	m_files = 0;
}

void DropSystem::release()
{
	DragAcceptFiles(m_prop->m_hWnd, false);
}

void DropSystem::printFiles(TemplateVector<char*>& a_dragged)
{
	//TCHAR lpszFiles[MAX_PATH] = {0};
	char * lpszFiles = new char[MAX_PATH];
	for (int i = 0; i < m_files; i++)
	{
		if (DragQueryFile(m_hdrop, i, lpszFiles, MAX_PATH))
		{
			a_dragged.add(lpszFiles);
			lpszFiles = new char[MAX_PATH];
			//MessageBoxA(NULL, lpszFiles, NULL, MB_ICONINFORMATION);
		}
	}
	delete [] lpszFiles;

}

void DropSystem::update()
{
	if(m_prop->m_hdrop)
	{
		m_hdrop = m_prop->m_hdrop;
		m_prop->m_hdrop = 0;
		m_files = DragQueryFile(m_hdrop,0xffffffff, NULL, NULL);
	}
	else
		m_files = 0;
}